package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsTopicSection;
import com.ruoyi.system.domain.news.query.NewsTopicSectionQuery;
import com.ruoyi.system.domain.news.vo.NewsTopicSectionVo;
import com.ruoyi.system.domain.news.vo.NewsTopicSectionVo;
import com.ruoyi.system.mapper.news.NewsTopicSectionMapper;
import com.ruoyi.system.service.news.NewsTopicSectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsTopicSectionServiceImpl extends ServiceImpl<NewsTopicSectionMapper, NewsTopicSection>
        implements NewsTopicSectionService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsTopicSectionVo> getNewsTopicSectionList(NewsTopicSectionQuery newsTopicSectionQuery) {
        if (newsTopicSectionQuery.getIfPage()) {
            PageHelper.startPage(newsTopicSectionQuery.getPageNum(), newsTopicSectionQuery.getPageSize());
        }
        List<NewsTopicSectionVo> newsTopicSectionVoList = baseMapper.getNewsTopicSectionList(newsTopicSectionQuery);
        if (!newsTopicSectionVoList.isEmpty() && newsTopicSectionQuery.getId() == null) {
            for (NewsTopicSectionVo newsTopicSectionVo:newsTopicSectionVoList) {
                newsTopicSectionVo.setContent(null);
            }
        }
        return newsTopicSectionVoList;
    }
}
